package com.conti.service.impl;

import com.conti.dto.DownTimeCodeDTO;
import com.conti.dto.LinePageQueryDTO;
import com.conti.dto.LineQueryDTO;
import com.conti.dto.ShiftBookDTO;
import com.conti.entity.CTAndCustomer;
import com.conti.entity.DowntimeReason;
import com.conti.entity.PartNumber;
import com.conti.mapper.prod.LineMapper;
import com.conti.result.PageResult;
import com.conti.service.LineService;
import com.conti.vo.LineNoPagingVO;
import com.conti.vo.LineVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LineServiceImpl implements LineService {
    @Autowired
    private LineMapper lineMapper;



    @Override
    public PageResult pageQuery(LinePageQueryDTO linePageQueryDTO) {
        PageHelper.startPage(linePageQueryDTO.getPage(), linePageQueryDTO.getPageSize());
        Page<LineVO> page=lineMapper.pageQuery(linePageQueryDTO);
        return new PageResult(page.getTotal(), page.getResult());
    }

    /**
     * 产线查询，无需分页版
     * @param lineQueryDTO
     * @return
     */
    @Override
    public List<LineNoPagingVO> queryNoPaging(LineQueryDTO lineQueryDTO) {
        return lineMapper.queryNoPaging(lineQueryDTO);
    }


    /**
     * 根据产线查询料号
     * @param line
     * @return
     */
    @Override
    public List<PartNumber> getPartNumberByLine(String line) {
        return lineMapper.getPartNumberByLine(line);
    }

    /**
     * 根据部门和产线查询停机原因
     * @param downTimeCodeDTO
     * @return
     */
    @Override
    public List<DowntimeReason> getDowntimeReason(DownTimeCodeDTO downTimeCodeDTO) {

        return lineMapper.getDowntimeReasonByPartAndLine(downTimeCodeDTO);
    }

    /**
     * 新增班次报表
     * @param shiftBookDTOList
     */
    @Override
    public void addNewShiftBook(List<ShiftBookDTO> shiftBookDTOList) {

    }


    /**
     * 查询料号的消费者和CT时间
     * @param partNumber
     * @param equipment
     * @return
     */
    @Override
    public CTAndCustomer getCTAndCustomer(String partNumber, String equipment) {
        return lineMapper.getCTAndCustomer(partNumber, equipment);
    }
}
